﻿using IAD13.fromTDDtoBDD.Exceptions;
using NUnit.Framework;

namespace IAD13.fromTDDtoBDD.TDD
{
    [TestFixture]
    public class AccountTests
    {
        private IAccount sut;

        [SetUp]
        public void SetUp()
        {
            // Arrange
            sut = new Account(Amount.OfEuro(0));
        }

        [Test]
        public void GetBalance()
        {
            // Act
            var result = sut.Balance();
            // Assert
            Assert.AreEqual(0,result.Value);
        }

        [Test]
        public void DoDeposit()
        {
            // Act
            sut.Deposit(Amount.OfEuro(100));
            // Assert
            Assert.AreEqual(Amount.OfEuro(100), sut.Balance());
        }

        [Test]
        public void DoWithdrawal()
        {
            // Arrange
            sut.Deposit(Amount.OfEuro(100));
            // Act
            sut.Withdrawal(Amount.OfEuro(80));
            // Assert
            Assert.AreEqual(Amount.OfEuro(20), sut.Balance());
        }

        [Test]
        public void DoWithdrawalGreaterThanBalance()
        {
            // Act
            Assert.Catch<WithdrawalGreaterThanBalanceException>(()=>sut.Withdrawal(Amount.OfEuro(80)));
            // Assert
            Assert.AreEqual(Amount.OfEuro(0), sut.Balance());
        }

        [Test]
        public void DoWithdrawalWithWrongCurrency()
        {
            // Act
            Assert.Catch<CurrencyIsWrongException>(() => sut.Withdrawal(Amount.OfDollar(80)));
            // Assert
            Assert.AreEqual(Amount.OfEuro(0), sut.Balance());
        }
        
        [Test]
        public void DoDepositWithWrongCurrency()
        {
            // Act
            Assert.Catch<CurrencyIsWrongException>(() => sut.Deposit(Amount.OfDollar(100)));
            // Assert
            Assert.AreEqual(Amount.OfEuro(0), sut.Balance());
        }
    }
}